﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Citrix.Cmp;
using Citrix.XaAdminMobile.ViewModel;

namespace Citrix.XaAdminMobile
{
    /// <summary>
    /// These are the different navigation implementations we support.
    /// </summary>
    internal enum NavigationLayout
    {
        Phone = 0,
        Tablet
    }

    /// <summary>
    /// The interface for providing different navigation implementations.
    /// </summary>
    interface INavigation
    {
        /// <summary>
        /// Returns the current back button navigation target that should be applied based on
        /// the navigation state.
        /// </summary>
        ButtonTarget BackButtonTarget { get; }

        /// <summary>
        /// Converts the current navigation state of this layout to a different layout.
        /// </summary>
        /// <param name="layout">The target navigation layout.</param>
        /// <returns>The new navigation implementation.</returns>
        INavigation Convert(NavigationLayout layout);

        /// <summary>
        /// Checks whether or not the specified page is being displayed.
        /// </summary>
        /// <param name="page">The page to check.</param>
        /// <returns>True if visible, false if not.</returns>
        bool IsActive(IPage page);

        /// <summary>
        /// Performs a back navigation operation to the previous page in the navigation history.
        /// </summary>
        void NavigateBack();

        /// <summary>
        /// Requests that the specified page be displayed.
        /// </summary>
        /// <param name="page">The page to display.</param>
        void NavigateForward(IPage page);

        /// <summary>
        /// Handler for a physical button press on the device.
        /// </summary>
        /// <param name="buttonId">The button that was pressed.</param>
        void NotifyButtonPressed(ButtonId buttonId);

        /// <summary>
        /// Fired whenever the page(s) to be displayed to the user have changed.
        /// </summary>
        /// <remarks>
        /// Implementers are assumed to implement this explicitly using weak references. If they
        /// don't then there will be a memory leak when switching between layouts.
        /// </remarks>
        event EventHandler PageChanged;
    }
}
